package com.blog.wu.myblog.redis;

import redis.clients.jedis.Jedis;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author wuyanshen
 * @Date 2019-01-03 10:57 AM
 * @Discription 使用jedis操作redis数据库
 */
public class RedisDemo {

    private static Jedis jedis = null;

    public static void main(String[] args) {
        jedis = new Jedis("localhost",6379);
//        jedis.auth("");
//        setString();
//        setMap();
//        setList();
        setSet();
    }

    public static void setString() {
        jedis.set("gitee","http://gitee.com");
        System.out.println("添加成功");
    }

    public static void setMap() {
        Map<String, String> map = new HashMap<String, String>();
        map.put("apple","12");
        map.put("banane","20");
        jedis.hmset("fruit",map);
        System.out.println("Map添加成功");
    }

    public static void setList() {
        jedis.lpush("lala", "100");
        jedis.lpush("lala", "200");
        System.out.println("List添加成功");
    }

    public static void setSet() {
        jedis.sadd("xiaobai", "300");
        jedis.sadd("xiaobai", "400");
        System.out.println("Set添加成功");
    }

    public static void setZSet() {
        System.out.println("ZSet添加成功");
    }
}
